﻿//https://leetcode.cn/problems/missing-number/ 

class Solution {
public:
    int missingNumber(vector<int>& nums)
    {
        int val = 0;
        int n = nums.size();
        //0^任何数都为任何数，任何数^任何数都为0

        for (auto e : nums)
        {
            val ^= e;
        }

        for (int i = 0; i <= n; i++)
        {
            val ^= i;
        }

        return val;

    }
};